/*
 * Copyright (c) 2016. For Intelligent Group.
 */

package com.intelligent.ispc.core.dto;

import com.intelligent.ispc.common.dto.AbstractValueObject;
import com.intelligent.ispc.common.mapper.BeanMapper;
import com.intelligent.ispc.core.entity.Project;
import com.intelligent.ispc.core.entity.ToleranceItem;
import com.intelligent.ispc.core.entity.ToleranceScheme;
import com.intelligent.ispc.core.repository.jpa.ProjectDao;
import com.intelligent.ispc.core.repository.jpa.ToleranceSchemeDao;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * Created by Peter on 2016/8/22.
 */
public class ToleranceSchemeDto extends AbstractValueObject {

    private Long id;
    private String name;
    private Long projectId;
    private Double usl;
    private Double lsl;
    private Integer calculateTimes;
    private List<ToleranceItemDto> items;


    public Long getId() { return id; }

    public void setId(Long id) { this.id = id; }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Double getUsl() { return usl; }

    public void setUsl(Double usl) { this.usl = usl; }

    public Double getLsl() { return lsl; }

    public void setLsl(Double lsl) { this.lsl = lsl; }

    public Integer getCalculateTimes() { return calculateTimes; }

    public void setCalculateTimes(Integer calculateTimes) { this.calculateTimes = calculateTimes; }

    public Long getProjectId() {
        return projectId;
    }

    public void setProjectId(Long projectId) {
        this.projectId = projectId;
    }

    public List<ToleranceItemDto> getItems() {
        return items;
    }

    public void setItems(List<ToleranceItemDto> items) {
        this.items = items;
    }

    public static void dtoToEntity(ToleranceSchemeDto dto, ToleranceScheme entity) {
        if(dto.getProjectId() != null){
            Project project = new Project();
            project.setId(dto.getProjectId());
            entity.setProject(project);
        }
        BeanMapper.copy(dto, entity);
    }
}
